home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#48 (Sep 89)
/
Zoundz Source
/
HandleTheMenus.Pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-05-01
|
6KB
|
227 lines
unit HandleTheMenus;
interface
uses
PrintTraps, Message, save_changes, About, Untitled, Sound, MyGlobals, MyFileStuff, MyPrintStuff;
procedure AdjustMenus;
procedure Handle_My_Menu (var doneFlag: boolean; theMenu, theItem: integer);{Handle menu selection}
implementation
procedure AdjustMenus;
begin
if (FrontWindow <> MyWindow) then
begin {Something up there}
DisableItem(M_Extend, 0);
EnableItem(M_Edit, 0);
DisableItem(M_File, MI_Open);
DisableItem(M_File, MI_New);
DisableItem(M_File, MI_Close);
DisableItem(M_File, MI_Save);
DisableItem(M_File, MI_Save_As);
DisableItem(M_File, MI_Page_Setup);
DisableItem(M_File, MI_Print);
end
else if MyWindow <> nil then
begin {My Window up there}
EnableItem(M_Extend, 0);
DisableItem(M_Edit, 0);
DisableItem(M_File, MI_Open);
DisableItem(M_File, MI_New);
EnableItem(M_File, MI_Close);
EnableItem(M_File, MI_Save);
EnableItem(M_File, MI_Save_As);
EnableItem(M_File, MI_Page_Setup);
EnableItem(M_File, MI_Print);
end
else
begin {nothing up there}
VolRefNum := 0; {no need to save any changes}
DisableItem(M_Extend, 0);
DisableItem(M_Edit, 0);
EnableItem(M_File, MI_Open);
EnableItem(M_File, MI_New);
DisableItem(M_File, MI_Close);
DisableItem(M_File, MI_Save);
DisableItem(M_File, MI_Save_As);
DisableItem(M_File, MI_Page_Setup);
DisableItem(M_File, MI_Print);
end;
end;
procedure Handle_My_Menu; {Handle menu selections realtime}
var
DNA: integer; {For opening DAs}
BoolHolder: boolean; {For SystemEdit result}
DAName, title: Str255; {For getting DA name}
SavePort: GrafPtr; {Save current port when opening DAs}
i, theValue: integer;
begin {Start of procedure}
case theMenu of {Do selected menu list}
L_Apple:
begin
case theItem of
MI_About_Zoundz:
begin
D_About;
end;
otherwise{Handle the DAs}
begin
GetPort(SavePort);
GetItem(AppleMenu, theItem, DAName);
DNA := OpenDeskAcc(DAName);
SetPort(SavePort);
end;
end; {End of item case}
end; {End for Apple Menu list}
L_File:
begin
case theItem of
MI_New:
begin
Init_Untitled;
Open_Untitled;
dirty := false;
end;
MI_Open:
begin
doOpen;
if VolRefNum <> 0 then
begin
Open_Untitled;
SetWTitle(MyWindow, FileName);
dirty := false;
end;
end;
MI_Close:
begin
if dirty then
begin {need saving}
GetWTitle(MyWindow, title);
ParamText(title, '', '', '');
theValue := D_save_changes;
if (theValue = I_Yes) then
begin {wants to save changes}
if VolRefNum = 0 then
doSaveAs
else
doSave;
if VolRefNum <> 0 then {did not cancel saving}
Close_Untitled(MyWindow);
end
else if theValue = I_No then
Close_Untitled(MyWindow);
end {of needing saved}
else {no need to save}
Close_Untitled(MyWindow);
end;
MI_Save:
begin
if VolRefNum = 0 then
doSaveAs
else
doSave;
if VolRefNum <> 0 then
dirty := false;
end;
MI_Save_As:
begin
doSaveAs;
if VolRefNum <> 0 then
dirty := false;
end;
MI_Page_Setup:
begin
doSetUp;
end;
MI_Print:
begin
doPrint;
end;
MI_Quit:
begin
if (MyWindow <> nil) and dirty then
begin {need saving}
GetWTitle(MyWindow, title);
ParamText(title, '', '', '');
theValue := D_save_changes;
case theValue of
I_Yes:
begin
if VolRefNum = 0 then
doSaveAs
else
doSave;
if VolRefNum <> 0 then {did not cancel saving}
doneFlag := TRUE;
end; {of Yes}
I_No:
doneFlag := True;
otherwise
;
end; {of case}
end {of needing saved}
else {no need to save}
doneFlag := TRUE;
end;
otherwise
;
end; {of item list}
end; {of File Menu List }
L_Edit:
begin
BoolHolder := SystemEdit(theItem - 1); {DA Editing}
end;
L_Extend:
begin
case theItem of{Handle extending values}
MI_Frequency:
begin
theValue := MyDoc^.freq[NoteIndex];
for i := MyDoc^.StartValue to MyDoc^.EndValue do
MyDoc^.freq[i] := theValue;
end; {of Frequency}
MI_Amplitude:
begin
theValue := MyDoc^.amp[NoteIndex];
for i := MyDoc^.StartValue to MyDoc^.EndValue do
MyDoc^.amp[i] := theValue;
end; {of Amplitude}
MI_Duration:
begin
theValue := MyDoc^.dur[NoteIndex];
for i := MyDoc^.StartValue to MyDoc^.EndValue do
MyDoc^.dur[i] := theValue;
end; {of duration}
MI_Timbre:
begin
theValue := MyDoc^.timbre[NoteIndex];
for i := MyDoc^.StartValue to MyDoc^.EndValue do
MyDoc^.timbre[i] := theValue;
end; {of timbre}
otherwise
;
end; { of items in Extend Menu}
InvalRect(NotePallete);
end; {of Extend Menu List}
otherwise
;
end; {End for the Menus}
HiliteMenu(0); {Turn menu selection off}
end; {End of procedure Handle_My_Menu}
end. {End of unit}